const localStorages = {
  set(key, value, time) {
    /* new Date().getTime(); 3600000 * 12 * 7 */
    time = time || 12;
    localStorage.setItem(key, JSON.stringify([value, (new Date().getTime() + 3600000 * time)]));
  },
  get(key) {
    const val = JSON.parse(localStorage.getItem(key));
    if (!val) { return }
    if (new Date().getTime() <= val[1]) {
      return val[0];
    }
    this.remove(key);
  },
  remove(key) {
    delete localStorage.session;
  }
};

export default localStorages
